package com.dietmanager.model;

import java.util.ArrayList;

/**
 * The Class Recipe is the model for recipe.
 */
public class Recipe extends FoodModel {
	private static final long serialVersionUID = 4302123763416823076L;
	private ArrayList<FoodModel> items = new ArrayList<>();

	/**
	 * Instantiates a new recipe.
	 *
	 * @param name the name
	 * @param amount the amount
	 */
	public Recipe(String name, int amount) {
		super(name, amount);
	}

	/**
	 * Adds the FoodModel
	 *
	 * @param food the food
	 */
	public void add(FoodModel food) {
		items.add(food);
	}
	
	/**
	 * Removes the FoodModel
	 *
	 * @param food the food
	 */
	public void remove(FoodModel food){
		items.remove(food);
	}

	/**
	 * Gets the calories.
	 *
	 * @return the name
	 */
	@Override
	public int getCalories() {
		int calories = 0;
		
		for(FoodModel item : items)
			calories += item.getCalories();
		
		return calories;
	}	

	/**
	 * Gets the fat.
	 *
	 * @return the name
	 */
	@Override
	public int getFat() {
		int fat = 0;
		
		for(FoodModel item : items)
			fat += item.getFat();
		
		return fat;
	}	

	/**
	 * Gets the carbohydrates.
	 *
	 * @return the name
	 */
	@Override
	public int getCarbohydrates() {
		int carbohydrates = 0;
		
		for(FoodModel item : items)
			carbohydrates += item.getCarbohydrates();
		
		return carbohydrates;
	}

	/**
	 * Gets the protein.
	 *
	 * @return the name
	 */
	@Override
	public int getProtein() {
		int protein = 0;
		
		for(FoodModel item : items)
			protein += item.getProtein();
		
		return protein;
	}
}
